﻿// <copyright file="TelegramReceivedEventArgs.cs" company="Hallvard Korsgaard">
//  Microsoft Public License (Ms-PL). See license details here: http://enoceannet.codeplex.com/license
// </copyright>
// <author>Hallvard Korsgaard</author>

namespace StcEthernet
{
  using System;
  using EnOcean;

  /// <summary>
  ///  Provides data for the TelegramReceived event.
  /// </summary>
  [Serializable]
  public class TelegramReceivedEventArgs : EventArgs
  {
    /// <summary>
    /// Gets the date and time when the message was received.
    /// </summary>
    private readonly DateTimeOffset timestamp = DateTimeOffset.Now;

    /// <summary>
    /// Initializes a new instance of the TelegramReceivedEventArgs class.
    /// </summary>
    /// <param name="telegram">The received telegram.</param>
    /// <param name="channel">The channel that reveived the telegram if the operation mode is normal. If operating in gateway mode parameter must be set to 0xFF.</param>
    internal TelegramReceivedEventArgs(Telegram telegram, byte channel)
    {
      this.Telegram = telegram;
      this.Channel = channel;
    }

    /// <summary>
    /// Gets the received telegram.
    /// </summary>
    public Telegram Telegram
    {
      get;
      private set;
    }

    /// <summary>
    /// Gets the channel that reveived the telegram if the operation mode is normal. If operating in gateway mode this property returns the value 0xFF.
    /// </summary>
    public byte Channel
    {
      get;
      private set;
    }

    /// <summary>
    /// Gets the date and time when the message was received.
    /// </summary>
    public DateTimeOffset Timestamp
    {
      get
      {
        return this.timestamp;
      }
    }
  }
}
